.class public Lde/dealdoktor/app/data/DataModel;
.super Ljava/lang/Object;
.source "DataModel.java"


# static fields
.field public static final DEFAULT_AVATAR:Ljava/lang/String; = "&d=http://www.dealdoktor.de/misc/app/dealdoktor_gravatar_grau_60x60.png"


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 20
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static getCategoryPosts(Landroid/content/Context;I)Ljava/util/ArrayList;
    .locals 4
    .parameter "context"
    .parameter "page"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/content/Context;",
            "I)",
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/PostDAO;",
            ">;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 26
    new-instance v1, Ljava/util/ArrayList;

    invoke-direct {v1}, Ljava/util/ArrayList;-><init>()V

    .line 27
    .local v1, categories:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Ljava/lang/Integer;>;"
    new-instance v3, Lde/dealdoktor/app/db/SelectedCategoriesModel;

    invoke-direct {v3, p0}, Lde/dealdoktor/app/db/SelectedCategoriesModel;-><init>(Landroid/content/Context;)V

    invoke-virtual {v3}, Lde/dealdoktor/app/db/SelectedCategoriesModel;->getAll()Landroid/database/Cursor;

    move-result-object v0

    .line 28
    .local v0, c:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v3

    if-eqz v3, :cond_1

    .line 30
    :cond_0
    const/4 v3, 0x0

    invoke-interface {v0, v3}, Landroid/database/Cursor;->getInt(I)I

    move-result v3

    invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    invoke-virtual {v1, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 31
    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z

    move-result v3

    .line 29
    if-nez v3, :cond_0

    .line 33
    :cond_1
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 35
    invoke-static {p1, v1}, Lde/dealdoktor/app/data/DataModel;->getPosts(ILjava/util/ArrayList;)Ljava/util/ArrayList;

    move-result-object v2

    .line 37
    .local v2, posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/PostDAO;>;"
    return-object v2
.end method

.method private static getPosts(ILjava/util/ArrayList;)Ljava/util/ArrayList;
    .locals 8
    .parameter "page"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(I",
            "Ljava/util/ArrayList",
            "<",
            "Ljava/lang/Integer;",
            ">;)",
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/PostDAO;",
            ">;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 41
    .local p1, categories:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Ljava/lang/Integer;>;"
    const-string v0, ""

    .line 42
    .local v0, categoriesString:Ljava/lang/String;
    const/4 v1, 0x0

    .local v1, i:I
    :goto_0
    invoke-virtual {p1}, Ljava/util/ArrayList;->size()I

    move-result v6

    if-lt v1, v6, :cond_0

    .line 50
    const-string v5, "http://www.dealdoktor.de/api/get_categories_posts/"

    .line 51
    .local v5, url:Ljava/lang/String;
    const-string v6, "c2dm"

    invoke-static {v6, v5}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 52
    new-instance v2, Landroid/os/Bundle;

    invoke-direct {v2}, Landroid/os/Bundle;-><init>()V

    .line 53
    .local v2, params:Landroid/os/Bundle;
    const-string v6, "page"

    invoke-static {p0}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v2, v6, v7}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 54
    const-string v6, "ids"

    invoke-virtual {v2, v6, v0}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 55
    const-string v6, "custom_fields"

    const-string v7, "ratings_score,sparpotential"

    invoke-virtual {v2, v6, v7}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 57
    const-string v6, "GET"

    invoke-static {v5, v6, v2}, Lde/dealdoktor/app/util/AsyncRequest;->request(Ljava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Ljava/lang/String;

    move-result-object v4

    .line 58
    .local v4, response:Ljava/lang/String;
    const-string v6, "response"

    invoke-static {v6, v5}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 59
    const-string v6, "response"

    invoke-static {v6, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 61
    invoke-static {v4}, Lde/dealdoktor/app/data/DataModel;->parsePosts(Ljava/lang/String;)Ljava/util/ArrayList;

    move-result-object v3

    .line 63
    .local v3, posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/PostDAO;>;"
    return-object v3

    .line 43
    .end local v2           #params:Landroid/os/Bundle;
    .end local v3           #posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/PostDAO;>;"
    .end local v4           #response:Ljava/lang/String;
    .end local v5           #url:Ljava/lang/String;
    :cond_0
    if-eqz v1, :cond_1

    .line 44
    new-instance v6, Ljava/lang/StringBuilder;

    invoke-static {v0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v7, ","

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {p1, v1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v7

    invoke-static {v7}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 42
    :goto_1
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 46
    :cond_1
    new-instance v6, Ljava/lang/StringBuilder;

    invoke-static {v0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1, v1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v7

    invoke-static {v7}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    goto :goto_1
.end method

.method public static getPostsForIds(Ljava/util/ArrayList;)Ljava/util/ArrayList;
    .locals 10
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/ArrayList",
            "<",
            "Ljava/lang/String;",
            ">;)",
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/PostDAO;",
            ">;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 247
    .local p0, ids:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Ljava/lang/String;>;"
    const-string v6, "http://www.dealdoktor.de/api/get_posts/"

    .line 248
    .local v6, url:Ljava/lang/String;
    new-instance v1, Landroid/os/Bundle;

    invoke-direct {v1}, Landroid/os/Bundle;-><init>()V

    .line 249
    .local v1, params:Landroid/os/Bundle;
    const-string v7, "custom_fields"

    const-string v8, "ratings_score,sparpotential"

    invoke-virtual {v1, v7, v8}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 251
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    .line 252
    .local v5, sb:Ljava/lang/StringBuilder;
    invoke-virtual {p0}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

    move-result-object v7

    :goto_0
    invoke-interface {v7}, Ljava/util/Iterator;->hasNext()Z

    move-result v8

    if-nez v8, :cond_0

    .line 255
    const/4 v7, 0x0

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->length()I

    move-result v8

    add-int/lit8 v8, v8, -0x1

    invoke-virtual {v5, v7, v8}, Ljava/lang/StringBuilder;->substring(II)Ljava/lang/String;

    move-result-object v0

    .line 256
    .local v0, idString:Ljava/lang/String;
    const-string v7, "ids"

    invoke-virtual {v1, v7, v0}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 258
    const-string v7, "POST"

    invoke-static {v6, v7, v1}, Lde/dealdoktor/app/util/AsyncRequest;->request(Ljava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Ljava/lang/String;

    move-result-object v3

    .line 260
    .local v3, response:Ljava/lang/String;
    invoke-static {v3}, Lde/dealdoktor/app/data/DataModel;->parsePosts(Ljava/lang/String;)Ljava/util/ArrayList;

    move-result-object v2

    .line 262
    .local v2, posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/PostDAO;>;"
    return-object v2

    .line 252
    .end local v0           #idString:Ljava/lang/String;
    .end local v2           #posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/PostDAO;>;"
    .end local v3           #response:Ljava/lang/String;
    :cond_0
    invoke-interface {v7}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Ljava/lang/String;

    .line 253
    .local v4, s:Ljava/lang/String;
    invoke-virtual {v5, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, ","

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    goto :goto_0
.end method

.method public static getRecentComments(I)Ljava/util/ArrayList;
    .locals 15
    .parameter "page"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(I)",
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/CommentDAO;",
            ">;"
        }
    .end annotation

    .prologue
    .line 227
    const-string v14, "http://www.dealdoktor.de/api/get_recent_comments/"

    .line 228
    .local v14, url:Ljava/lang/String;
    new-instance v12, Landroid/os/Bundle;

    invoke-direct {v12}, Landroid/os/Bundle;-><init>()V

    .line 229
    .local v12, params:Landroid/os/Bundle;
    const-string v0, "page"

    invoke-static {p0}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v12, v0, v1}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 230
    new-instance v7, Ljava/util/ArrayList;

    invoke-direct {v7}, Ljava/util/ArrayList;-><init>()V

    .line 232
    .local v7, comments:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/CommentDAO;>;"
    :try_start_0
    const-string v0, "GET"

    invoke-static {v14, v0, v12}, Lde/dealdoktor/app/util/AsyncRequest;->request(Ljava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Ljava/lang/String;

    move-result-object v13

    .line 233
    .local v13, response:Ljava/lang/String;
    new-instance v10, Lorg/json/JSONObject;

    invoke-direct {v10, v13}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 234
    .local v10, json:Lorg/json/JSONObject;
    const-string v0, "comments"

    invoke-virtual {v10, v0}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v11

    .line 236
    .local v11, jsonComments:Lorg/json/JSONArray;
    const/4 v9, 0x0

    .local v9, j:I
    :goto_0
    invoke-virtual {v11}, Lorg/json/JSONArray;->length()I

    move-result v0

    if-lt v9, v0, :cond_0

    .line 243
    .end local v9           #j:I
    .end local v10           #json:Lorg/json/JSONObject;
    .end local v11           #jsonComments:Lorg/json/JSONArray;
    .end local v13           #response:Ljava/lang/String;
    :goto_1
    return-object v7

    .line 237
    .restart local v9       #j:I
    .restart local v10       #json:Lorg/json/JSONObject;
    .restart local v11       #jsonComments:Lorg/json/JSONArray;
    .restart local v13       #response:Ljava/lang/String;
    :cond_0
    invoke-virtual {v11, v9}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v6

    .line 238
    .local v6, comment:Lorg/json/JSONObject;
    new-instance v0, Lde/dealdoktor/app/data/CommentDAO;

    const-string v1, "date"

    invoke-virtual {v6, v1}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    const-string v2, "name"

    invoke-virtual {v6, v2}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    const-string v3, "content"

    invoke-virtual {v6, v3}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    new-instance v4, Ljava/lang/StringBuilder;

    const-string v5, "avatar"

    invoke-virtual {v6, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v5, "&d=http://www.dealdoktor.de/misc/app/dealdoktor_gravatar_grau_60x60.png"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    const-string v5, "post_id"

    invoke-virtual {v6, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    invoke-direct/range {v0 .. v5}, Lde/dealdoktor/app/data/CommentDAO;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v7, v0}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 236
    add-int/lit8 v9, v9, 0x1

    goto :goto_0

    .line 240
    .end local v6           #comment:Lorg/json/JSONObject;
    .end local v9           #j:I
    .end local v10           #json:Lorg/json/JSONObject;
    .end local v11           #jsonComments:Lorg/json/JSONArray;
    .end local v13           #response:Ljava/lang/String;
    :catch_0
    move-exception v8

    .line 241
    .local v8, e:Ljava/lang/Exception;
    const-string v0, "exception"

    const-string v1, "Exception in DataModel getRecentComments"

    invoke-static {v0, v1, v8}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_1
.end method

.method public static getSearchResults(Ljava/lang/String;IZ)Ljava/util/ArrayList;
    .locals 26
    .parameter "searchQuery"
    .parameter "page"
    .parameter "sortByDate"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "IZ)",
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/PostDAO;",
            ">;"
        }
    .end annotation

    .prologue
    .line 115
    const-string v25, "http://www.dealdoktor.de/api/get_search_results/"

    .line 116
    .local v25, url:Ljava/lang/String;
    new-instance v21, Landroid/os/Bundle;

    invoke-direct/range {v21 .. v21}, Landroid/os/Bundle;-><init>()V

    .line 117
    .local v21, params:Landroid/os/Bundle;
    const-string v2, "search"

    move-object/from16 v0, v21

    move-object/from16 v1, p0

    invoke-virtual {v0, v2, v1}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 118
    const-string v2, "page"

    invoke-static/range {p1 .. p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v3

    move-object/from16 v0, v21

    invoke-virtual {v0, v2, v3}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 119
    const-string v2, "custom_fields"

    const-string v3, "ratings_score,sparpotential"

    move-object/from16 v0, v21

    invoke-virtual {v0, v2, v3}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 120
    if-eqz p2, :cond_0

    .line 121
    const-string v2, "orderby"

    const-string v3, "post_date"

    move-object/from16 v0, v21

    invoke-virtual {v0, v2, v3}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 122
    const-string v2, "order"

    const-string v3, "desc"

    move-object/from16 v0, v21

    invoke-virtual {v0, v2, v3}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 124
    :cond_0
    new-instance v23, Ljava/util/ArrayList;

    invoke-direct/range {v23 .. v23}, Ljava/util/ArrayList;-><init>()V

    .line 126
    .local v23, posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/PostDAO;>;"
    :try_start_0
    const-string v2, "GET"

    move-object/from16 v0, v25

    move-object/from16 v1, v21

    invoke-static {v0, v2, v1}, Lde/dealdoktor/app/util/AsyncRequest;->request(Ljava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Ljava/lang/String;

    move-result-object v24

    .line 127
    .local v24, response:Ljava/lang/String;
    new-instance v18, Lorg/json/JSONObject;

    move-object/from16 v0, v18

    move-object/from16 v1, v24

    invoke-direct {v0, v1}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 128
    .local v18, json:Lorg/json/JSONObject;
    const-string v2, "posts"

    move-object/from16 v0, v18

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v20

    .line 129
    .local v20, jsonPosts:Lorg/json/JSONArray;
    const/16 v16, 0x0

    .local v16, i:I
    :goto_0
    invoke-virtual/range {v20 .. v20}, Lorg/json/JSONArray;->length()I

    move-result v2

    move/from16 v0, v16

    if-lt v0, v2, :cond_1

    .line 159
    .end local v16           #i:I
    .end local v18           #json:Lorg/json/JSONObject;
    .end local v20           #jsonPosts:Lorg/json/JSONArray;
    .end local v24           #response:Ljava/lang/String;
    :goto_1
    return-object v23

    .line 130
    .restart local v16       #i:I
    .restart local v18       #json:Lorg/json/JSONObject;
    .restart local v20       #jsonPosts:Lorg/json/JSONArray;
    .restart local v24       #response:Ljava/lang/String;
    :cond_1
    move-object/from16 v0, v20

    move/from16 v1, v16

    invoke-virtual {v0, v1}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v22

    .line 131
    .local v22, post:Lorg/json/JSONObject;
    const-string v2, "comments"

    move-object/from16 v0, v22

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v19

    .line 132
    .local v19, jsonComments:Lorg/json/JSONArray;
    new-instance v10, Ljava/util/ArrayList;

    invoke-direct {v10}, Ljava/util/ArrayList;-><init>()V

    .line 133
    .local v10, comments:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/CommentDAO;>;"
    const/16 v17, 0x0

    .local v17, j:I
    :goto_2
    invoke-virtual/range {v19 .. v19}, Lorg/json/JSONArray;->length()I

    move-result v2

    move/from16 v0, v17

    if-lt v0, v2, :cond_2

    .line 138
    const-string v7, ""

    .line 139
    .local v7, image:Ljava/lang/String;
    const-string v11, ""

    .line 140
    .local v11, ratingScore:Ljava/lang/String;
    const-string v12, ""
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 142
    .local v12, sparPotential:Ljava/lang/String;
    :try_start_1
    const-string v2, "attachments"

    move-object/from16 v0, v22

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v2

    invoke-virtual {v2}, Lorg/json/JSONArray;->length()I

    move-result v2

    if-lez v2, :cond_3

    const-string v2, "attachments"

    move-object/from16 v0, v22

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v2

    const/4 v3, 0x0

    invoke-virtual {v2, v3}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "images"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "medium"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "url"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_3

    move-result-object v7

    .line 145
    :goto_3
    :try_start_2
    const-string v2, "custom_fields"

    move-object/from16 v0, v22

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "ratings_score"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v14

    .line 146
    .local v14, data:Lorg/json/JSONArray;
    invoke-virtual {v14}, Lorg/json/JSONArray;->length()I

    move-result v2

    if-lez v2, :cond_4

    const/4 v2, 0x0

    invoke-virtual {v14, v2}, Lorg/json/JSONArray;->getString(I)Ljava/lang/String;
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_2

    move-result-object v11

    .line 149
    .end local v14           #data:Lorg/json/JSONArray;
    :goto_4
    :try_start_3
    const-string v2, "custom_fields"

    move-object/from16 v0, v22

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "sparpotential"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v14

    .line 150
    .restart local v14       #data:Lorg/json/JSONArray;
    invoke-virtual {v14}, Lorg/json/JSONArray;->length()I

    move-result v2

    if-lez v2, :cond_5

    const/4 v2, 0x0

    invoke-virtual {v14, v2}, Lorg/json/JSONArray;->getString(I)Ljava/lang/String;
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_1

    move-result-object v12

    .line 152
    .end local v14           #data:Lorg/json/JSONArray;
    :goto_5
    :try_start_4
    const-string v2, "xxxxxx"

    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "id"

    move-object/from16 v0, v22

    invoke-virtual {v0, v4}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v4

    invoke-static {v4}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v4, "    "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 153
    new-instance v2, Lde/dealdoktor/app/data/PostDAO;

    const-string v3, "id"

    move-object/from16 v0, v22

    invoke-virtual {v0, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v3

    const-string v4, "date"

    move-object/from16 v0, v22

    invoke-virtual {v0, v4}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    const-string v5, "title"

    move-object/from16 v0, v22

    invoke-virtual {v0, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    const-string v6, "content"

    move-object/from16 v0, v22

    invoke-virtual {v0, v6}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v6

    const-string v8, "url"

    move-object/from16 v0, v22

    invoke-virtual {v0, v8}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v10}, Ljava/util/ArrayList;->size()I

    move-result v9

    invoke-direct/range {v2 .. v12}, Lde/dealdoktor/app/data/PostDAO;-><init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/util/ArrayList;Ljava/lang/String;Ljava/lang/String;)V

    move-object/from16 v0, v23

    invoke-virtual {v0, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 129
    add-int/lit8 v16, v16, 0x1

    goto/16 :goto_0

    .line 135
    .end local v7           #image:Ljava/lang/String;
    .end local v11           #ratingScore:Ljava/lang/String;
    .end local v12           #sparPotential:Ljava/lang/String;
    :cond_2
    move-object/from16 v0, v19

    move/from16 v1, v17

    invoke-virtual {v0, v1}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v13

    .line 136
    .local v13, comment:Lorg/json/JSONObject;
    new-instance v2, Lde/dealdoktor/app/data/CommentDAO;

    const-string v3, "date"

    invoke-virtual {v13, v3}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    const-string v4, "name"

    invoke-virtual {v13, v4}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    const-string v5, "content"

    invoke-virtual {v13, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    const-string v6, ""

    invoke-direct {v2, v3, v4, v5, v6}, Lde/dealdoktor/app/data/CommentDAO;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v10, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_4
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_0

    .line 133
    add-int/lit8 v17, v17, 0x1

    goto/16 :goto_2

    .line 142
    .end local v13           #comment:Lorg/json/JSONObject;
    .restart local v7       #image:Ljava/lang/String;
    .restart local v11       #ratingScore:Ljava/lang/String;
    .restart local v12       #sparPotential:Ljava/lang/String;
    :cond_3
    :try_start_5
    const-string v7, ""
    :try_end_5
    .catch Ljava/lang/Exception; {:try_start_5 .. :try_end_5} :catch_3

    goto/16 :goto_3

    .line 146
    .restart local v14       #data:Lorg/json/JSONArray;
    :cond_4
    :try_start_6
    const-string v11, ""
    :try_end_6
    .catch Ljava/lang/Exception; {:try_start_6 .. :try_end_6} :catch_2

    goto/16 :goto_4

    .line 150
    :cond_5
    :try_start_7
    const-string v12, ""
    :try_end_7
    .catch Ljava/lang/Exception; {:try_start_7 .. :try_end_7} :catch_1

    goto/16 :goto_5

    .line 155
    .end local v7           #image:Ljava/lang/String;
    .end local v10           #comments:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/CommentDAO;>;"
    .end local v11           #ratingScore:Ljava/lang/String;
    .end local v12           #sparPotential:Ljava/lang/String;
    .end local v14           #data:Lorg/json/JSONArray;
    .end local v16           #i:I
    .end local v17           #j:I
    .end local v18           #json:Lorg/json/JSONObject;
    .end local v19           #jsonComments:Lorg/json/JSONArray;
    .end local v20           #jsonPosts:Lorg/json/JSONArray;
    .end local v22           #post:Lorg/json/JSONObject;
    .end local v24           #response:Ljava/lang/String;
    :catch_0
    move-exception v15

    .line 156
    .local v15, e:Ljava/lang/Exception;
    const-string v2, "excpetion"

    const-string v3, "Exception in DataModel"

    invoke-static {v2, v3, v15}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto/16 :goto_1

    .line 151
    .end local v15           #e:Ljava/lang/Exception;
    .restart local v7       #image:Ljava/lang/String;
    .restart local v10       #comments:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/CommentDAO;>;"
    .restart local v11       #ratingScore:Ljava/lang/String;
    .restart local v12       #sparPotential:Ljava/lang/String;
    .restart local v16       #i:I
    .restart local v17       #j:I
    .restart local v18       #json:Lorg/json/JSONObject;
    .restart local v19       #jsonComments:Lorg/json/JSONArray;
    .restart local v20       #jsonPosts:Lorg/json/JSONArray;
    .restart local v22       #post:Lorg/json/JSONObject;
    .restart local v24       #response:Ljava/lang/String;
    :catch_1
    move-exception v2

    goto/16 :goto_5

    .line 147
    :catch_2
    move-exception v2

    goto/16 :goto_4

    .line 143
    :catch_3
    move-exception v2

    goto/16 :goto_3
.end method

.method public static getTopDeals()Ljava/util/ArrayList;
    .locals 6
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/PostDAO;",
            ">;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 67
    const-string v4, "xxxxxx"

    const-string v5, "top deals"

    invoke-static {v4, v5}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 68
    const-string v3, "http://www.dealdoktor.de/api/get_top_deals/"

    .line 70
    .local v3, url:Ljava/lang/String;
    new-instance v0, Landroid/os/Bundle;

    invoke-direct {v0}, Landroid/os/Bundle;-><init>()V

    .line 71
    .local v0, params:Landroid/os/Bundle;
    const-string v4, "custom_fields"

    const-string v5, "ratings_score,sparpotential"

    invoke-virtual {v0, v4, v5}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 74
    const-string v4, "GET"

    invoke-static {v3, v4, v0}, Lde/dealdoktor/app/util/AsyncRequest;->request(Ljava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Ljava/lang/String;

    move-result-object v2

    .line 75
    .local v2, response:Ljava/lang/String;
    const-string v4, "response"

    invoke-static {v4, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 76
    const-string v4, "response"

    invoke-static {v4, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 78
    invoke-static {v2}, Lde/dealdoktor/app/data/DataModel;->parsePosts(Ljava/lang/String;)Ljava/util/ArrayList;

    move-result-object v1

    .line 80
    .local v1, posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/PostDAO;>;"
    return-object v1
.end method

.method private static parsePosts(Ljava/lang/String;)Ljava/util/ArrayList;
    .locals 22
    .parameter "response"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            ")",
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/PostDAO;",
            ">;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/json/JSONException;
        }
    .end annotation

    .prologue
    .line 84
    new-instance v21, Ljava/util/ArrayList;

    invoke-direct/range {v21 .. v21}, Ljava/util/ArrayList;-><init>()V

    .line 85
    .local v21, posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/PostDAO;>;"
    new-instance v17, Lorg/json/JSONObject;

    move-object/from16 v0, v17

    move-object/from16 v1, p0

    invoke-direct {v0, v1}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 86
    .local v17, json:Lorg/json/JSONObject;
    const-string v2, "posts"

    move-object/from16 v0, v17

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v19

    .line 87
    .local v19, jsonPosts:Lorg/json/JSONArray;
    const/4 v15, 0x0

    .local v15, i:I
    :goto_0
    invoke-virtual/range {v19 .. v19}, Lorg/json/JSONArray;->length()I

    move-result v2

    if-lt v15, v2, :cond_0

    .line 111
    return-object v21

    .line 88
    :cond_0
    move-object/from16 v0, v19

    invoke-virtual {v0, v15}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v20

    .line 89
    .local v20, post:Lorg/json/JSONObject;
    const-string v2, "comments"

    move-object/from16 v0, v20

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v18

    .line 90
    .local v18, jsonComments:Lorg/json/JSONArray;
    new-instance v10, Ljava/util/ArrayList;

    invoke-direct {v10}, Ljava/util/ArrayList;-><init>()V

    .line 91
    .local v10, comments:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/CommentDAO;>;"
    const/16 v16, 0x0

    .local v16, j:I
    :goto_1
    invoke-virtual/range {v18 .. v18}, Lorg/json/JSONArray;->length()I

    move-result v2

    move/from16 v0, v16

    if-lt v0, v2, :cond_1

    .line 95
    const-string v7, ""

    .line 96
    .local v7, image:Ljava/lang/String;
    const-string v11, ""

    .line 97
    .local v11, ratingScore:Ljava/lang/String;
    const-string v12, ""

    .line 99
    .local v12, sparPotential:Ljava/lang/String;
    :try_start_0
    const-string v2, "attachments"

    move-object/from16 v0, v20

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v2

    invoke-virtual {v2}, Lorg/json/JSONArray;->length()I

    move-result v2

    if-lez v2, :cond_2

    const-string v2, "attachments"

    move-object/from16 v0, v20

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v2

    const/4 v3, 0x0

    invoke-virtual {v2, v3}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "images"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "medium"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "url"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_2

    move-result-object v7

    .line 102
    :goto_2
    :try_start_1
    const-string v2, "custom_fields"

    move-object/from16 v0, v20

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "ratings_score"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v14

    .line 103
    .local v14, data:Lorg/json/JSONArray;
    invoke-virtual {v14}, Lorg/json/JSONArray;->length()I

    move-result v2

    if-lez v2, :cond_3

    const/4 v2, 0x0

    invoke-virtual {v14, v2}, Lorg/json/JSONArray;->getString(I)Ljava/lang/String;
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    move-result-object v11

    .line 106
    .end local v14           #data:Lorg/json/JSONArray;
    :goto_3
    :try_start_2
    const-string v2, "custom_fields"

    move-object/from16 v0, v20

    invoke-virtual {v0, v2}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v2

    const-string v3, "sparpotential"

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v14

    .line 107
    .restart local v14       #data:Lorg/json/JSONArray;
    invoke-virtual {v14}, Lorg/json/JSONArray;->length()I

    move-result v2

    if-lez v2, :cond_4

    const/4 v2, 0x0

    invoke-virtual {v14, v2}, Lorg/json/JSONArray;->getString(I)Ljava/lang/String;
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    move-result-object v12

    .line 109
    .end local v14           #data:Lorg/json/JSONArray;
    :goto_4
    new-instance v2, Lde/dealdoktor/app/data/PostDAO;

    const-string v3, "id"

    move-object/from16 v0, v20

    invoke-virtual {v0, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v3

    const-string v4, "date"

    move-object/from16 v0, v20

    invoke-virtual {v0, v4}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    const-string v5, "title"

    move-object/from16 v0, v20

    invoke-virtual {v0, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    const-string v6, "content"

    move-object/from16 v0, v20

    invoke-virtual {v0, v6}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v6

    const-string v8, "url"

    move-object/from16 v0, v20

    invoke-virtual {v0, v8}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v10}, Ljava/util/ArrayList;->size()I

    move-result v9

    invoke-direct/range {v2 .. v12}, Lde/dealdoktor/app/data/PostDAO;-><init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/util/ArrayList;Ljava/lang/String;Ljava/lang/String;)V

    move-object/from16 v0, v21

    invoke-virtual {v0, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 87
    add-int/lit8 v15, v15, 0x1

    goto/16 :goto_0

    .line 92
    .end local v7           #image:Ljava/lang/String;
    .end local v11           #ratingScore:Ljava/lang/String;
    .end local v12           #sparPotential:Ljava/lang/String;
    :cond_1
    move-object/from16 v0, v18

    move/from16 v1, v16

    invoke-virtual {v0, v1}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v13

    .line 93
    .local v13, comment:Lorg/json/JSONObject;
    new-instance v2, Lde/dealdoktor/app/data/CommentDAO;

    const-string v3, "date"

    invoke-virtual {v13, v3}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    const-string v4, "name"

    invoke-virtual {v13, v4}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    const-string v5, "content"

    invoke-virtual {v13, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    new-instance v6, Ljava/lang/StringBuilder;

    const-string v8, "avatar"

    invoke-virtual {v13, v8}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v8

    invoke-static {v8}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v8

    invoke-direct {v6, v8}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v8, "&d=http://www.dealdoktor.de/misc/app/dealdoktor_gravatar_grau_60x60.png"

    invoke-virtual {v6, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-direct {v2, v3, v4, v5, v6}, Lde/dealdoktor/app/data/CommentDAO;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v10, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 91
    add-int/lit8 v16, v16, 0x1

    goto/16 :goto_1

    .line 99
    .end local v13           #comment:Lorg/json/JSONObject;
    .restart local v7       #image:Ljava/lang/String;
    .restart local v11       #ratingScore:Ljava/lang/String;
    .restart local v12       #sparPotential:Ljava/lang/String;
    :cond_2
    :try_start_3
    const-string v7, ""
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_2

    goto/16 :goto_2

    .line 103
    .restart local v14       #data:Lorg/json/JSONArray;
    :cond_3
    :try_start_4
    const-string v11, ""
    :try_end_4
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_1

    goto/16 :goto_3

    .line 107
    :cond_4
    :try_start_5
    const-string v12, ""
    :try_end_5
    .catch Ljava/lang/Exception; {:try_start_5 .. :try_end_5} :catch_0

    goto/16 :goto_4

    .line 108
    .end local v14           #data:Lorg/json/JSONArray;
    :catch_0
    move-exception v2

    goto/16 :goto_4

    .line 104
    :catch_1
    move-exception v2

    goto/16 :goto_3

    .line 100
    :catch_2
    move-exception v2

    goto/16 :goto_2
.end method

.method public static sendRegistrationId(Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;
    .locals 9
    .parameter "c"
    .parameter "registrationId"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 276
    const-string v6, "dealdoktor_preferences"

    const/4 v7, 0x0

    invoke-virtual {p0, v6, v7}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v4

    .line 278
    .local v4, settings:Landroid/content/SharedPreferences;
    const-string v6, "installationId"

    const-string v7, ""

    invoke-interface {v4, v6, v7}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    .line 279
    .local v1, installationId:Ljava/lang/String;
    const-string v6, ""

    invoke-virtual {v1, v6}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v6

    if-eqz v6, :cond_0

    .line 281
    invoke-static {}, Ljava/util/UUID;->randomUUID()Ljava/util/UUID;

    move-result-object v6

    invoke-virtual {v6}, Ljava/util/UUID;->toString()Ljava/lang/String;

    move-result-object v1

    .line 282
    invoke-interface {v4}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v0

    .line 283
    .local v0, editor:Landroid/content/SharedPreferences$Editor;
    const-string v6, "installationId"

    invoke-interface {v0, v6, v1}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 284
    invoke-interface {v0}, Landroid/content/SharedPreferences$Editor;->commit()Z

    .line 287
    .end local v0           #editor:Landroid/content/SharedPreferences$Editor;
    :cond_0
    const-string v5, "http://www.dealdoktor.de/api/register_c2dm_device"

    .line 288
    .local v5, url:Ljava/lang/String;
    new-instance v2, Landroid/os/Bundle;

    invoke-direct {v2}, Landroid/os/Bundle;-><init>()V

    .line 289
    .local v2, params:Landroid/os/Bundle;
    const-string v6, "registration_id"

    invoke-virtual {v2, v6, p1}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 290
    const-string v6, "installation_id"

    invoke-virtual {v2, v6, v1}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 291
    const-string v6, "POST"

    invoke-static {v5, v6, v2}, Lde/dealdoktor/app/util/AsyncRequest;->request(Ljava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Ljava/lang/String;

    move-result-object v3

    .line 292
    .local v3, response:Ljava/lang/String;
    const-string v6, "xxx"

    new-instance v7, Ljava/lang/StringBuilder;

    const-string v8, "Send registrationId response:"

    invoke-direct {v7, v8}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v7, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-static {v6, v7}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 293
    return-object v3
.end method

.method public static submitComment(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lde/dealdoktor/app/data/CommentDAO;
    .locals 10
    .parameter "postId"
    .parameter "name"
    .parameter "email"
    .parameter "content"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 211
    const-string v4, "http://www.dealdoktor.de/api/submit_comment/"

    .line 212
    .local v4, url:Ljava/lang/String;
    new-instance v2, Landroid/os/Bundle;

    invoke-direct {v2}, Landroid/os/Bundle;-><init>()V

    .line 213
    .local v2, params:Landroid/os/Bundle;
    const-string v5, "name"

    new-instance v6, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v7, " [Android]"

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v2, v5, v6}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 214
    const-string v5, "email"

    invoke-virtual {v2, v5, p2}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 215
    const-string v5, "content"

    invoke-virtual {v2, v5, p3}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 216
    const-string v5, "post_id"

    invoke-virtual {v2, v5, p0}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 218
    const/4 v0, 0x0

    .line 219
    .local v0, comment:Lde/dealdoktor/app/data/CommentDAO;
    const-string v5, "POST"

    invoke-static {v4, v5, v2}, Lde/dealdoktor/app/util/AsyncRequest;->request(Ljava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Ljava/lang/String;

    move-result-object v3

    .line 220
    .local v3, response:Ljava/lang/String;
    new-instance v1, Lorg/json/JSONObject;

    invoke-direct {v1, v3}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 221
    .local v1, json:Lorg/json/JSONObject;
    new-instance v0, Lde/dealdoktor/app/data/CommentDAO;

    .end local v0           #comment:Lde/dealdoktor/app/data/CommentDAO;
    const-string v5, "date"

    invoke-virtual {v1, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    const-string v6, "name"

    invoke-virtual {v1, v6}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v6

    const-string v7, "content"

    invoke-virtual {v1, v7}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    new-instance v8, Ljava/lang/StringBuilder;

    const-string v9, "avatar"

    invoke-virtual {v1, v9}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v9

    invoke-static {v9}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v9

    invoke-direct {v8, v9}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v9, "&d=http://www.dealdoktor.de/misc/app/dealdoktor_gravatar_grau_60x60.png"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-direct {v0, v5, v6, v7, v8}, Lde/dealdoktor/app/data/CommentDAO;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 223
    .restart local v0       #comment:Lde/dealdoktor/app/data/CommentDAO;
    return-object v0
.end method


# virtual methods
.method public getCategories(Landroid/content/Context;)Ljava/util/ArrayList;
    .locals 20
    .parameter "c"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/content/Context;",
            ")",
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/CategoriesDAO;",
            ">;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 163
    const-string v17, "http://www.dealdoktor.de/api/get_category_index/"

    .line 164
    .local v17, url:Ljava/lang/String;
    new-instance v14, Landroid/os/Bundle;

    invoke-direct {v14}, Landroid/os/Bundle;-><init>()V

    .line 165
    .local v14, params:Landroid/os/Bundle;
    new-instance v9, Ljava/util/ArrayList;

    invoke-direct {v9}, Ljava/util/ArrayList;-><init>()V

    .line 166
    .local v9, categories:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/CategoriesDAO;>;"
    new-instance v2, Lde/dealdoktor/app/db/CategoriesModel;

    move-object/from16 v0, p1

    invoke-direct {v2, v0}, Lde/dealdoktor/app/db/CategoriesModel;-><init>(Landroid/content/Context;)V

    .line 168
    .local v2, model:Lde/dealdoktor/app/db/CategoriesModel;
    const-string v3, "GET"

    move-object/from16 v0, v17

    invoke-static {v0, v3, v14}, Lde/dealdoktor/app/util/AsyncRequest;->request(Ljava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Ljava/lang/String;

    move-result-object v15

    .line 170
    .local v15, response:Ljava/lang/String;
    new-instance v12, Lorg/json/JSONObject;

    invoke-direct {v12, v15}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 171
    .local v12, json:Lorg/json/JSONObject;
    const-string v3, "categories"

    invoke-virtual {v12, v3}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v13

    .line 173
    .local v13, jsonCategories:Lorg/json/JSONArray;
    invoke-virtual {v2}, Lde/dealdoktor/app/db/CategoriesModel;->resetUpdateStatus()V

    .line 174
    const/4 v11, 0x0

    .local v11, i:I
    :goto_0
    invoke-virtual {v13}, Lorg/json/JSONArray;->length()I

    move-result v3

    if-lt v11, v3, :cond_0

    .line 189
    const/4 v11, 0x0

    :goto_1
    invoke-virtual {v13}, Lorg/json/JSONArray;->length()I

    move-result v3

    if-lt v11, v3, :cond_3

    .line 206
    invoke-virtual {v2}, Lde/dealdoktor/app/db/CategoriesModel;->deleteOldCategories()V

    .line 207
    return-object v9

    .line 175
    :cond_0
    invoke-virtual {v13, v11}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v10

    .line 176
    .local v10, category:Lorg/json/JSONObject;
    const-string v3, "parent"

    invoke-virtual {v10, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v6

    .line 177
    .local v6, parent:I
    if-nez v6, :cond_1

    .line 178
    const-string v3, "id"

    invoke-virtual {v10, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v3

    invoke-virtual {v2, v3}, Lde/dealdoktor/app/db/CategoriesModel;->hasCategory(I)Z

    move-result v3

    if-eqz v3, :cond_2

    .line 179
    const-string v3, "id"

    invoke-virtual {v10, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v3

    invoke-virtual {v2, v3}, Lde/dealdoktor/app/db/CategoriesModel;->getSelectedStatus(I)Z

    move-result v16

    .line 180
    .local v16, selected:Z
    new-instance v3, Lde/dealdoktor/app/data/CategoriesDAO;

    const-string v4, "id"

    invoke-virtual {v10, v4}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v4

    const-string v5, "title"

    invoke-virtual {v10, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    const-string v7, "description"

    invoke-virtual {v10, v7}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    move/from16 v0, v16

    invoke-direct {v3, v4, v5, v7, v0}, Lde/dealdoktor/app/data/CategoriesDAO;-><init>(ILjava/lang/String;Ljava/lang/String;Z)V

    invoke-virtual {v9, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 181
    const-string v3, "id"

    invoke-virtual {v10, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v3

    const-string v4, "title"

    invoke-virtual {v10, v4}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    const-string v5, "description"

    invoke-virtual {v10, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v2, v3, v4, v5, v6}, Lde/dealdoktor/app/db/CategoriesModel;->update(ILjava/lang/String;Ljava/lang/String;I)V

    .line 174
    .end local v16           #selected:Z
    :cond_1
    :goto_2
    add-int/lit8 v11, v11, 0x1

    goto :goto_0

    .line 183
    :cond_2
    new-instance v3, Lde/dealdoktor/app/data/CategoriesDAO;

    const-string v4, "id"

    invoke-virtual {v10, v4}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v4

    const-string v5, "title"

    invoke-virtual {v10, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    const-string v7, "description"

    invoke-virtual {v10, v7}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    const/16 v18, 0x1

    move/from16 v0, v18

    invoke-direct {v3, v4, v5, v7, v0}, Lde/dealdoktor/app/data/CategoriesDAO;-><init>(ILjava/lang/String;Ljava/lang/String;Z)V

    invoke-virtual {v9, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 184
    const-string v3, "id"

    invoke-virtual {v10, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v3

    const-string v4, "title"

    invoke-virtual {v10, v4}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    const-string v5, "description"

    invoke-virtual {v10, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v2, v3, v4, v5, v6}, Lde/dealdoktor/app/db/CategoriesModel;->insert(ILjava/lang/String;Ljava/lang/String;I)V

    goto :goto_2

    .line 190
    .end local v6           #parent:I
    .end local v10           #category:Lorg/json/JSONObject;
    :cond_3
    invoke-virtual {v13, v11}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v10

    .line 191
    .restart local v10       #category:Lorg/json/JSONObject;
    const-string v3, "parent"

    invoke-virtual {v10, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v6

    .line 192
    .restart local v6       #parent:I
    if-eqz v6, :cond_5

    .line 193
    invoke-virtual {v9}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

    move-result-object v3

    :cond_4
    invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z

    move-result v4

    if-nez v4, :cond_6

    .line 189
    :cond_5
    :goto_3
    add-int/lit8 v11, v11, 0x1

    goto/16 :goto_1

    .line 193
    :cond_6
    invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v8

    check-cast v8, Lde/dealdoktor/app/data/CategoriesDAO;

    .line 194
    .local v8, cat:Lde/dealdoktor/app/data/CategoriesDAO;
    iget v4, v8, Lde/dealdoktor/app/data/CategoriesDAO;->id:I

    if-ne v4, v6, :cond_4

    .line 195
    iget-object v3, v8, Lde/dealdoktor/app/data/CategoriesDAO;->subCategories:Ljava/util/ArrayList;

    new-instance v4, Lde/dealdoktor/app/data/CategoriesDAO;

    const-string v5, "id"

    invoke-virtual {v10, v5}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v5

    const-string v7, "title"

    invoke-virtual {v10, v7}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    const-string v18, "description"

    move-object/from16 v0, v18

    invoke-virtual {v10, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v18

    iget-boolean v0, v8, Lde/dealdoktor/app/data/CategoriesDAO;->selected:Z

    move/from16 v19, v0

    move-object/from16 v0, v18

    move/from16 v1, v19

    invoke-direct {v4, v5, v7, v0, v1}, Lde/dealdoktor/app/data/CategoriesDAO;-><init>(ILjava/lang/String;Ljava/lang/String;Z)V

    invoke-virtual {v3, v4}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 196
    const-string v3, "id"

    invoke-virtual {v10, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v3

    invoke-virtual {v2, v3}, Lde/dealdoktor/app/db/CategoriesModel;->hasCategory(I)Z

    move-result v3

    if-eqz v3, :cond_7

    .line 197
    const-string v3, "id"

    invoke-virtual {v10, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v3

    const-string v4, "title"

    invoke-virtual {v10, v4}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    const-string v5, "description"

    invoke-virtual {v10, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v2, v3, v4, v5, v6}, Lde/dealdoktor/app/db/CategoriesModel;->update(ILjava/lang/String;Ljava/lang/String;I)V

    goto :goto_3

    .line 199
    :cond_7
    const-string v3, "id"

    invoke-virtual {v10, v3}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v3

    const-string v4, "title"

    invoke-virtual {v10, v4}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    const-string v5, "description"

    invoke-virtual {v10, v5}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    iget-boolean v7, v8, Lde/dealdoktor/app/data/CategoriesDAO;->selected:Z

    invoke-virtual/range {v2 .. v7}, Lde/dealdoktor/app/db/CategoriesModel;->insert(ILjava/lang/String;Ljava/lang/String;IZ)V

    goto :goto_3
.end method
